package disjunction.extensions.view
{
	
	/**
	 * 
	 *
	 * @author Nick Wiggill
	 */
	
	public class DisplayObjectEntityAdder implements IEntityAdder
	{
		public function add(entity:*):void
		{
			//will throw cast error if element in entity view list is incorrect type
			var entityView:EntityView = _entitiesByModel[entity];
			entityView.model = entity;
			if (entityView == null)
			{
				//creator is non optional, so we will fail with a NPE if the creator is null
				entityView = entityCreator.create(entity); //createFor()?
				
				//add to own lists (entities)
				_entities.push(entityView);
				_entitiesByModel[entity] = entityView;
				
				//add to rendering system list (displayobjects)
				context.addChild((entityView as DisplayObjectEntity2D).displayObject);
			}
		}
	}
}